package com.kindnesslibrary.ximage;

import java.io.Serializable;
import java.util.ArrayList;

/**
 * Created by lenovo on 2017/6/3.
 * XImage配置
 */
public class XImgSelConfig implements Serializable {

    /**
     * 预选中的图片
     */
    public ArrayList<String> selectImage;

    /**
     * 是否需要裁剪
     */
    public boolean needCrop;

    /**
     * 是否需要预览
     */
    public boolean needPreview;

    /**
     * 第一个item是否显示相机
     */
    public boolean needCamera;

    /**
     * 自定义图片加载器
     */
    public XImageLoader loader;

    /**
     * 最多选择图片数
     */
    public int maxNum = 9;

    public XImgSelConfig(Builder builder) {
        this.needCamera = builder.showCamera;
        this.needPreview = builder.isPreview;
        this.needCrop = builder.isCrop;
        this.loader = builder.xImageLoader;
        this.maxNum = builder.maxNum;
        selectImage = new ArrayList<>();
    }

    public XImgSelConfig setImageLoader(XImageLoader xImageLoader){
        this.loader = xImageLoader;
        return this;
    }

    public static class Builder{

        private String btnConfirmText = "完成";
        private int maxNum = 9;
        private boolean isPreview;
        private boolean showCamera;
        private boolean isCrop;
        private XImageLoader xImageLoader;

        public Builder(XImageLoader xImageLoader){
            this.xImageLoader = xImageLoader;
        }

        public Builder btnConfirmText(String text){
            this.btnConfirmText = text;
            return this;
        }

        public Builder maxNum(int maxNum){
            this.maxNum = maxNum;
            return this;
        }

        public Builder isPreview(){
            this.isPreview = true;
            return this;
        }

        public Builder showCamera(boolean showCamera){
            this.showCamera = showCamera;
            return this;
        }

        public Builder isCrop(boolean isCrop){
            this.isCrop = isCrop;
            return this;
        }

        public Builder setImageLoader(XImageLoader xImageLoader){
            this.xImageLoader = xImageLoader;
            return this;
        }

        public XImgSelConfig build(){
            return new XImgSelConfig(this);
        }

    }

}
